<template>
    <el-container style="height: 1000px; border: 1px solid #eee">
        <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
            <el-menu :default-openeds="['1','3']">
<!--                循环绑定菜单-->
<!--                只要每次的值不一样就不会全部展开-->
                <el-submenu :index="menu.action" v-for="menu in menus">
                    <template slot="title"><i class="el-icon-message"></i>{{menu.title}}</template>
<!--                    遍历子菜单的子菜单-->
                    <router-link :to="item.path" v-for="item in menu.items">
                        <el-submenu>
                            <template slot="title">{{item.title}}</template>
                        </el-submenu>
                    </router-link>
                </el-submenu>
            </el-menu>
        </el-aside>

        <el-container>
            <el-header style="text-align: right; font-size: 12px">
                <el-dropdown>
                    <i class="el-icon-setting" style="margin-right: 15px"></i>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>查看</el-dropdown-item>
                        <el-dropdown-item>新增</el-dropdown-item>
                        <el-dropdown-item>删除</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
                <span>王小虎</span>
            </el-header>

            <el-main>
<!--                路由挂载-->
              <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
    // 导入菜单数据
    import menus from "../menu";
    export default {
        name: "Index",
        data() {
            return {
                menus:menus  //声明菜单数据
            }
        },
        mounted() {
            // this.$http.get("http://api.blb.com/api/goods-api/test").
            // then(res=>{
            //     console.log(res)
            // });
        }
    };
</script>

<style scoped>
    .el-header {
        background-color: #B3C0D1;
        color: #333;
        line-height: 60px;
    }
    a{
        text-decoration: none;
    }
    .el-aside {
        color: #333;
    }
</style>